
from libPlugins import *


#
# This is a scanner function that can scan the file line-by-line.
# The function is called once for each line in the input file. THe filename
# and current line number is passed to the function. The function returns
# a boolean value indicating whether it wants more input (True), or whether
# it does not care any moer about this file (False).
#
# errors are reported using reportError(line, col)
#
def scanLine(line, filename, currentLine):
	# this returns the appropriate type:
	getOption('name1')

	if 'todo' in line:
		# report a problem. arguments are line, column:
		reportError(currentLine, 0)
		return true



# similar to the above, but this one gets passed a single file object:
def scanFile(fobj):
	nLine = 0
	for line in fobj:
		if 'todo' in line:
			reportError(nLine,0)
		nLine += 1
			

# again, a similar method, but this one just gets a file path:
def scanFileName(fpath):
	# don't care about .cpp files:
	if fpath[-4:].lower() == '.cpp':
		return
	
	for line in file(fpath):
		pass
		# do scanning here:

describePlugin('loopsemi', 'scanner', 'Checks for semi-colons after loop statements.')

addOption('name0','type','description','default')
addOption('name1','type','description','default')
addOption('name2','type','description','default')
addOption('name3','type','description','default')


setScanFunction(SCANNER_TYPE_LINE_BY_LINE, scanLine)


